import java.lang.reflect.Array;
import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }

    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String,List<String>> map=new HashMap<>();
        for(String str:strs){
            char[] array=str.toCharArray();
            Arrays.sort(array);
            String key=new String(array);
            if(map.containsKey(key)){
                List<String> list=map.get(key);
                list.add(str);
                map.put(key,list);
            }else{
                List<String> list=new LinkedList<String>();
                list.add(str);
                map.put(key,list);
            }
        }
        return new LinkedList<List<String>>(map.values());
    }
}